package com.yunzheng.modoules.enrollAndLogin.login.service;

import com.yunzheng.modoules.enrollAndLogin.login.dao.UserDao;
import com.yunzheng.modoules.enrollAndLogin.login.dao.UserDaoImpl;
import com.yunzheng.modoules.enrollAndLogin.login.entity.Admin;

public class UserServiceImpl implements UserService{
    UserDao userDao = new UserDaoImpl();
    @Override
    public boolean isLogin(String phone_num, String password) throws Exception {
        String pwd = userDao.queryPwd(phone_num);
        if (password.equals(pwd)){
            return true;
        }
        return false;
    }

    @Override
    public boolean isExist(String phone_num) throws Exception {
        Integer id = userDao.queryId(phone_num);
        if (id!=0){
            return true;
        }
        return false;
    }

    @Override
    public String getLoginMsg(String phone_num, String password) throws Exception {
        Admin admin = new Admin();
        if (!isExist(phone_num) || phone_num != admin.getAdminPhone()) {
            return "不存在该用户名！";
        } else if (!isLogin(phone_num,password) || admin.getAdminPwd() != password) {
            return "用户名与密码不匹配！";
        }
        return null;
    }

}
